package com.rabbitmq.delay.receiver;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

import static com.rabbitmq.delay.config.RabbitConfig.DEAD_LETTER_QUEUE_A;
import static com.rabbitmq.delay.config.RabbitConfig.DEAD_LETTER_QUEUE_B;

/**
 * @author zhangwu
 * @create2021/6/16
 */
@Component
@Slf4j
public class DeadLetterReceive {

    //监听死信队列a
    @RabbitListener(queues = DEAD_LETTER_QUEUE_A)
    public void receiveA(Message message){
        String string = new String(message.getBody());
       log.info("当前时间:【{}】,死信队列A监听到的消息:[{}]", LocalDateTime.now(),string);
    }
    //监听死信队列b
    @RabbitListener(queues = DEAD_LETTER_QUEUE_B)
    public void receiveB(Message message){
        String string = new String(message.getBody());
        log.info("当前时间:【{}】,死信队列B监听到的消息:[{}]", LocalDateTime.now(),string);
    }
}
